package org.judking.CarKeeper.service;

import org.judking.CarKeeper.command.EarlyWarning.CoolantTemperatureDetector;
import org.judking.CarKeeper.command.EarlyWarning.FuelLevelDetector;
import org.judking.CarKeeper.command.EarlyWarning.SpeedCrashAlarm;
import org.judking.CarKeeper.command.EarlyWarning.WarmUpCheck;

public class EarlyWarningService {
	private static CoolantTemperatureDetector ctd;
	private static FuelLevelDetector fld;
	private static WarmUpCheck wuc;
	private static SpeedCrashAlarm sca;
	
	/************************* register ******************************/
	public static void register(CoolantTemperatureDetector ctd)		{
		EarlyWarningService.ctd = ctd;
	}
	
	public static void register(FuelLevelDetector fld)		{
		EarlyWarningService.fld = fld;
	}
	
	public static void register(WarmUpCheck wuc)			{
		EarlyWarningService.wuc = wuc;
	}
	
	public static void register(SpeedCrashAlarm sca)				{
		EarlyWarningService.sca = sca;
	}
	
	/************************* set configure ******************************/
	public static void setCoolantUpperBound(double upperBound)			{
		ctd.setUpperBound(upperBound);
	}
	
	public static void setCoolantLowerBound(double lowerBound)			{
		ctd.setLowerBound(lowerBound);
	}
	
	public static void setFuelLowerBound(double lowerBound)		{
		FuelLevelDetector.lowerBound = lowerBound;
	}
	
	public static void setWarmUpTime(double time)		{
		//time unit: second
		wuc.setTimeAfterIgnitionBound(time);
	}
	
	public static void setCarCrashPhoneNumber(String phoneNumber)		{
		SpeedCrashAlarm.guardianPhoneNo = phoneNumber;
	}
	
	/************************* get configure ******************************/
	public static double getCoolantUpperBound()			{
		return ctd.getUpperBound();
	}
	
	public static double getCoolantLowerBound()			{
		return ctd.getLowerBound();
	}
	
	public static double getFuelLowerBound()		{
		return FuelLevelDetector.lowerBound;
	}
	
	public static double getWarmUpTime()		{
		//time unit: second
		return wuc.getTimeAfterIgnitionBound();
	}
	
	public static String getCarCrashPhoneNumber()		{
		return SpeedCrashAlarm.guardianPhoneNo;
	}
}
